function init(market){
    var map = new AMap.Map('admap', {
        resizeEnable: true,
        center: [market.mLng, market.mLat],
        zoom: 12
    });
    map.plugin(["AMap.ToolBar"], function() {
        map.addControl(new AMap.ToolBar());
    });
    //
    var marker;
    marker = new AMap.Marker({
        icon: "http://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
        position: [market.mLng, market.mLat],
        map:map
    });
    console.log(marker)
    //marker.setMap(map);
    AMap.event.addListener(marker, 'click', function() {
    });
    //实例化信息窗体
    var title = market.mName+'<span style="font-size:11px;color:#F00;"></span>',
        content = [];
    content.push("<img style='width:85px;' src='"+market.mPic+"'><span style='white-space: nowrap;overflow: hidden;text-overflow: ellipsis;display: block;'>地址："+market.mAddr+"</span><span>电话："+market.mManagertel+"</span><span style='    white-space: nowrap;overflow: hidden;text-overflow: ellipsis;display: block;max-width: 230px;'>详细信息："+market.mIntroduction+"</span>");
    var infoWindow = new AMap.InfoWindow({
        isCustom: true,  //使用自定义窗体
        content: createInfoWindow(title, content.join("<br/>")),
        offset: new AMap.Pixel(16, -45)
    });
//鼠标点击marker弹出自定义的信息窗体
    AMap.event.addListener(marker, 'click', function() {
        infoWindow.open(map, marker.getPosition());
    });
    infoWindow.open(map, marker.getPosition());
    //构建自定义信息窗体
    function createInfoWindow(title, content) {
        var info = document.createElement("div");
        info.className = "info";

        //可以通过下面的方式修改自定义窗体的宽高
        //info.style.width = "400px";
        // 定义顶部标题
        var top = document.createElement("div");
        var titleD = document.createElement("div");
        var closeX = document.createElement("img");
        top.className = "info-top";
        titleD.innerHTML = title;
        closeX.src = "http://webapi.amap.com/images/close2.gif";
        closeX.onclick = closeInfoWindow;

        top.appendChild(titleD);
        top.appendChild(closeX);
        info.appendChild(top);

        // 定义中部内容
        var middle = document.createElement("div");
        middle.className = "info-middle";
        middle.style.backgroundColor = 'white';
        middle.innerHTML = content;
        info.appendChild(middle);

        // 定义底部内容
        var bottom = document.createElement("div");
        bottom.className = "info-bottom";
        bottom.style.position = 'relative';
        bottom.style.top = '0px';
        bottom.style.margin = '0 auto';
        var sharp = document.createElement("img");
        sharp.src = "http://webapi.amap.com/images/sharp.png";
        bottom.appendChild(sharp);
        info.appendChild(bottom);
        return info;
    }

    //关闭信息窗体
    function closeInfoWindow() {
        map.clearInfoWindow();
    }









    /* var info = [];
     info.push("<div><div><img style=\"float:left;\" src=\" http://webapi.amap.com/images/autonavi.png \"/></div> ");
     info.push("地址："+address+"</div></div>");
     infoWindow = new AMap.InfoWindow({
         content: info.join("<br/>")  //使用默认信息窗体框样式，显示信息内容
     });
     infoWindow.open(map, map.getCenter());*/
}


function regeocoder(market,success) {  //逆地理编码

    var lnglatXY = [market.mLng, market.mLat]; //已知点坐标
    var geocoder = new AMap.Geocoder({
        radius: 1000,
        extensions: "base"
    });
    console.log(lnglatXY);
    geocoder.getAddress(lnglatXY, success)

        /*function(status, result) {
        if (status === 'complete' && result.info === 'OK') {
            //geocoder_CallBack(result);
            return result.regeocode.addressComponent.city;
        }
      /!* geocoder_CallBack(result)*!/

    })*/;
}
/*function geocoder_CallBack(data) {
    console.log(data)
    var address = data.regeocode.addressComponent.city; //返回地址描述
    return address;
}*/




/*逆地理编码*/










/*时间转换(时间戳改为标准格式的时间)*/
function time(paytype) {
    if(paytype==null||paytype==''){

    }else {
        var date='/Date('+paytype+')/';
        //return jsonDateFormat(date,"yyyy-MM-dd hh:mm:ss")
        return jsonDateFormat(date,"yyyy-MM-dd")
    }
}
/*原生js*/
function jsonDateFormat (jsonDt, format) {
    var date, timestamp, dtObj;
    timestamp = jsonDt.replace(/\/Date\((\d+)\)\//, "$1");
    date = new Date(Number(timestamp));
    dtObj = {
        "M+": date.getMonth() + 1,   //月
        "d+": date.getDate(),        //日
        "h+": date.getHours(),       //时
        "m+": date.getMinutes(),     //分
        "s+": date.getSeconds(),     //秒
    };
    //因为年份是4位数，所以单独拿出来处理
    if (/(y+)/.test(format)) {
        format = format.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    //遍历dtObj
    for (var k in dtObj) {
        //dtObj的属性名作为正则进行匹配
        if (new RegExp("(" + k + ")").test(format)) {
            //月，日，时，分，秒 小于10时前面补 0
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? dtObj[k] : ("00" + dtObj[k]).substr(("" + dtObj[k]).length));
        }
    }
    return format;
}
var jssor_1_slider_init = function() {
    var jssor_1_SlideshowTransitions = [
        {$Duration:1200,x:0.3,$During:{$Left:[0.3,0.7]},$Easing:{$Left:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,x:-0.3,$SlideOut:true,$Easing:{$Left:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,x:-0.3,$During:{$Left:[0.3,0.7]},$Easing:{$Left:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,x:0.3,$SlideOut:true,$Easing:{$Left:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,y:0.3,$During:{$Top:[0.3,0.7]},$Easing:{$Top:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,y:-0.3,$SlideOut:true,$Easing:{$Top:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,y:-0.3,$During:{$Top:[0.3,0.7]},$Easing:{$Top:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,y:0.3,$SlideOut:true,$Easing:{$Top:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,x:0.3,$Cols:2,$During:{$Left:[0.3,0.7]},$ChessMode:{$Column:3},$Easing:{$Left:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,x:0.3,$Cols:2,$SlideOut:true,$ChessMode:{$Column:3},$Easing:{$Left:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,y:0.3,$Rows:2,$During:{$Top:[0.3,0.7]},$ChessMode:{$Row:12},$Easing:{$Top:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,y:0.3,$Rows:2,$SlideOut:true,$ChessMode:{$Row:12},$Easing:{$Top:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,y:0.3,$Cols:2,$During:{$Top:[0.3,0.7]},$ChessMode:{$Column:12},$Easing:{$Top:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,y:-0.3,$Cols:2,$SlideOut:true,$ChessMode:{$Column:12},$Easing:{$Top:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,x:0.3,$Rows:2,$During:{$Left:[0.3,0.7]},$ChessMode:{$Row:3},$Easing:{$Left:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,x:-0.3,$Rows:2,$SlideOut:true,$ChessMode:{$Row:3},$Easing:{$Left:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,x:0.3,y:0.3,$Cols:2,$Rows:2,$During:{$Left:[0.3,0.7],$Top:[0.3,0.7]},$ChessMode:{$Column:3,$Row:12},$Easing:{$Left:$Jease$.$InCubic,$Top:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,x:0.3,y:0.3,$Cols:2,$Rows:2,$During:{$Left:[0.3,0.7],$Top:[0.3,0.7]},$SlideOut:true,$ChessMode:{$Column:3,$Row:12},$Easing:{$Left:$Jease$.$InCubic,$Top:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,$Delay:20,$Clip:3,$Assembly:260,$Easing:{$Clip:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,$Delay:20,$Clip:3,$SlideOut:true,$Assembly:260,$Easing:{$Clip:$Jease$.$OutCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,$Delay:20,$Clip:12,$Assembly:260,$Easing:{$Clip:$Jease$.$InCubic,$Opacity:$Jease$.$Linear},$Opacity:2},
        {$Duration:1200,$Delay:20,$Clip:12,$SlideOut:true,$Assembly:260,$Easing:{$Clip:$Jease$.$OutCubic,$Opacity:$Jease$.$Linear},$Opacity:2}
    ];

    var jssor_1_options = {
        $AutoPlay: true,
        $AutoPlayInterval: 3000,
        $PauseOnHover: 1,
        $DragOrientation: 1,
        $ArrowKeyNavigation: true,
        $SlideDuration: 500,
        $SlideshowOptions: {
            $Class: $JssorSlideshowRunner$,
            $Transitions: jssor_1_SlideshowTransitions,
            $TransitionsOrder: 1
        },
        $ArrowNavigatorOptions: {
            $Class: $JssorArrowNavigator$
        },
        $ThumbnailNavigatorOptions: {
            $Class: $JssorThumbnailNavigator$,
            $Cols: 10,
            $SpacingX: 3,
            $SpacingY: 3,
            $Align: 1040
        }
    };
    var jssor_1_slider = new $JssorSlider$("jssor_1", jssor_1_options);
    function ScaleSlider() {
        var refSize = jssor_1_slider.$Elmt.parentNode.clientWidth;
        if (refSize) {
            refSize = Math.min(refSize, 1200);
            jssor_1_slider.$ScaleWidth(refSize);
        }
        else {
            window.setTimeout(ScaleSlider, 30);
        }
    }
    ScaleSlider();
    $Jssor$.$AddEvent(window, "load", ScaleSlider);
    $Jssor$.$AddEvent(window, "resize", ScaleSlider);
    $Jssor$.$AddEvent(window, "orientationchange", ScaleSlider);
};




/**
 * 这是基于html5的前端图片工具，压缩工具。
 */
var ImageResizer = function (opts) {
    var settings = {
        resizeMode: "auto"//压缩模式，总共有三种  auto,width,height auto表示自动根据最大的宽度及高度等比压缩，width表示只根据宽度来判断是否需要等比例压缩，height类似。
        , dataSource: "" //数据源。数据源是指需要压缩的数据源，有三种类型，image图片元素，base64字符串，canvas对象，还有选择文件时候的file对象。。。
        , dataSourceType: "image" //image  base64 canvas
        , maxWidth: 500 //允许的最大宽度
        , maxHeight: 500 //允许的最大高度。
        , onTmpImgGenerate: function (img) {
        } //当中间图片生成时候的执行方法。。这个时候请不要乱修改这图片，否则会打乱压缩后的结果。
        , success: function (resizeImgBase64, canvas) {

        }//压缩成功后图片的base64字符串数据。
    };
    var appData = {};
    $.extend(settings, opts);

    var innerTools = {
        getBase4FromImgFile: function (file, callBack) {
            var reader = new FileReader();
            reader.onload = function (e) {
                var base64Img = e.target.result;
                if (callBack) {
                    callBack(base64Img);
                }
            };
            reader.readAsDataURL(file);
        },

        //--处理数据源。。。。将所有数据源都处理成为图片对象，方便处理。
        getImgFromDataSource: function (datasource, dataSourceType, callback) {
            var _me = this;
            var img1 = new Image();
            if (dataSourceType == "img" || dataSourceType == "image") {
                img1.src = $(datasource).attr("src");
                if (callback) {
                    callback(img1);
                }
            }
            else if (dataSourceType == "base64") {
                img1.src = datasource;
                if (callback) {
                    callback(img1);
                }
            }
            else if (dataSourceType == "canvas") {
                img1.src = datasource.toDataURL("image/jpeg");
                if (callback) {
                    callback(img1);
                }
            }
            else if (dataSourceType == "file") {
                _me.getBase4FromImgFile(function (base64str) {
                    img1.src = base64str;
                    if (callback) {
                        callback(img1);
                    }
                });
            }
        },

        //计算图片的需要压缩的尺寸。当然，压缩模式，压缩限制直接从setting里面取出来。
        getResizeSizeFromImg: function (img) {
            //alert(JSON.stringify(img.getAttribute("src")));
            var _img_info = {
                w: $(img)[0].naturalWidth,
                h: $(img)[0].naturalHeight
            };

            /*var _resize_info={
             w:0,
             h:0
             };*/

            if (_img_info.w <= settings.maxWidth && _img_info.h <= settings.maxHeight) {
                return _img_info;
            }
            if (settings.resizeMode == "auto") {
                var _percent_scale = parseFloat(_img_info.w / _img_info.h);
                var _size1 = {
                    w: 0,
                    h: 0
                };
                var _size_by_mw = {
                    w: settings.maxWidth,
                    h: parseInt(settings.maxWidth / _percent_scale)
                };
                var _size_by_mh = {
                    w: parseInt(settings.maxHeight * _percent_scale),
                    h: settings.maxHeight
                };
                if (_size_by_mw.h <= settings.maxHeight) {
                    return _size_by_mw;
                }
                if (_size_by_mh.w <= settings.maxWidth) {
                    return _size_by_mh;
                }

                return {
                    w: settings.maxWidth,
                    h: settings.maxHeight
                };
            }
            if (settings.resizeMode == "width") {
                if (_img_info.w <= settings.maxWidth) {
                    return _img_info;
                }
                var _size_by_mw = {
                    w: settings.maxWidth
                    , h: parseInt(settings.maxWidth / _percent_scale)
                };
                return _size_by_mw;
            }
            if (settings.resizeMode == "height") {
                if (_img_info.h <= settings.maxHeight) {
                    return _img_info;
                }
                var _size_by_mh = {
                    w: parseInt(settings.maxHeight * _percent_scale)
                    , h: settings.maxHeight
                };
                return _size_by_mh;
            }
        },

        //--将相关图片对象画到canvas里面去。
        drawToCanvas: function (img, theW, theH, realW, realH, callback) {

            var canvas = document.createElement("canvas");
            canvas.width = theW;
            canvas.height = theH;
            var ctx = canvas.getContext('2d');
            ctx.drawImage(img,
                0,//sourceX,
                0,//sourceY,
                realW,//sourceWidth,
                realH,//sourceHeight,
                0,//destX,
                0,//destY,
                theW,//destWidth,
                theH//destHeight
            );
            //--获取base64字符串及canvas对象传给success函数。
            var base64str = canvas.toDataURL("image/png");
            if (callback) {
                callback(base64str, canvas);
            }
        }
    };

    //--开始处理。
    (function () {
        innerTools.getImgFromDataSource(settings.dataSource, settings.dataSourceType, function (_tmp_img) {
            var __tmpImg = _tmp_img;
            settings.onTmpImgGenerate(_tmp_img);
            //--计算尺寸。
            var _limitSizeInfo = innerTools.getResizeSizeFromImg(__tmpImg);
            var _img_info = {
                w: $(__tmpImg)[0].naturalWidth,
                h: $(__tmpImg)[0].naturalHeight
            };
            innerTools.drawToCanvas(__tmpImg, _limitSizeInfo.w, _limitSizeInfo.h, _img_info.w, _img_info.h, function (base64str, canvas) {
                settings.success(base64str, canvas);
            });
        });
    })();

    var returnObject = {};

    return returnObject;
};
function dataURLtoBlob(dataurl) {
    var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
        bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
    while (n--) {
        u8arr[n] = bstr.charCodeAt(n);
    }
    return new Blob([u8arr], {type: mime});
}


// function str2asc(strstr){
//     return ("0"+strstr.charCodeAt(0).toString(16)).slice(-2);
// }
// function asc2str(ascasc){
//     return String.fromCharCode(ascasc);
// }
//
// /*这里开始时UrlEncode和UrlDecode函数*/
// function UrlEncode(str){
//     var ret="";
//     var strSpecial="!\"#$%&'()*+,/:;<=>?[]^`{|}~%";
//     var tt= "";
//     for(var i=0;i<str.length;i++){
//         var chr = str.charAt(i);
//         var c=str2asc(chr);
//         tt += chr+":"+c+"n";
//         if(parseInt("0x"+c) > 0x7f){
//             ret+="%"+c.slice(0,2)+"%"+c.slice(-2);
//         }else{
//             if(chr==" ")
//                 ret+="+";
//             else if(strSpecial.indexOf(chr)!=-1)
//                 ret+="%"+c.toString(16);
//             else
//                 ret+=chr;
//         }
//     }
//     return ret;
// }
// function UrlDecode(str){
//     var ret="";
//     for(var i=0;i<str.length;i++){
//         var chr = str.charAt(i);
//         if(chr == "+"){
//             ret+=" ";
//         }else if(chr=="%"){
//             var asc = str.substring(i+1,i+3);
//             if(parseInt("0x"+asc)>0x7f){
//                 ret+=asc2str(parseInt("0x"+asc+str.substring(i+4,i+6)));
//                 i+=5;
//             }else{
//                 ret+=asc2str(parseInt("0x"+asc));
//                 i+=2;
//             }
//         }else{
//             ret+= chr;
//         }
//     }
//     return ret;
// }
